//
//  UIView+XHHAdditions.m
//  XHH_MeiTuan
//
//  Created by xiaohuihui on 2016/10/12.
//  Copyright © 2016年 30-陈辉华. All rights reserved.
//

#import "UIView+XHHAdditions.h"

@implementation UIView (XHHAdditions)

-(void)setXhh_size:(CGSize)xhh_size
{
    CGRect frame = self.frame;
    frame.size = xhh_size;
    self.frame = frame;
}
-(CGSize)xhh_size
{
    return self.frame.size;
}
-(void)setXhh_width:(CGFloat)xhh_width
{
    CGRect frame = self.frame;
    frame.size.width = xhh_width;
    self.frame = frame;
}
-(CGFloat)xhh_width
{
    return self.frame.size.width;
}

-(void)setXhh_height:(CGFloat)xhh_height
{
    CGRect frame = self.frame;
    frame.size.height = xhh_height;
    self.frame = frame;
}
-(CGFloat)xhh_height
{
    return self.frame.size.height;
}
-(void)setXhh_x:(CGFloat)xhh_x
{
    CGRect frame = self.frame;
    frame.origin.x = xhh_x;
    self.frame = frame;
}
-(CGFloat)xhh_x
{
    return self.frame.origin.x;
}
-(void)setXhh_y:(CGFloat)xhh_y
{
    CGRect frame = self.frame;
    frame.origin.y = xhh_y;
    self.frame = frame;
}
-(CGFloat)xhh_y
{
    return self.frame.origin.y;
}
-(void)setXhh_centerX:(CGFloat)xhh_centerX
{
    CGPoint center = self.center;
    center.x = xhh_centerX;
    self.center = center;
}
-(CGFloat)xhh_centerX
{
    return self.center.x;
}
-(void)setXhh_centerY:(CGFloat)xhh_centerY
{
    CGPoint center = self.center;
    center.y = xhh_centerY;
    self.center = center;
}
-(CGFloat)xhh_centerY
{
    return self.center.y;
}
-(void)setXhh_right:(CGFloat)xhh_right
{
    self.xhh_x = xhh_right - self.xhh_width;
}
-(CGFloat)xhh_right
{
    return CGRectGetMaxX(self.frame);
}
-(void)setXhh_bottom:(CGFloat)xhh_bottom
{
    self.xhh_y = xhh_bottom - self.xhh_height;
}
-(CGFloat)xhh_bottom
{
    return CGRectGetMaxY(self.frame);
}
+(instancetype)xhh_viewFromNib
{
    return [[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;
}
-(BOOL)xhh_intersectWithView:(UIView *)view
{
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    CGRect newRect = [self convertRect:self.bounds toView:window];
    CGRect newView = [view convertRect:view.bounds toView:window];
    return CGRectIntersectsRect(newRect, newView);
}

@end
